/**
 * Copyright 2011 Micro_SNS Group. All Right reserved.
 */
package com.team.sns.services.impl;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.team.sns.entities.UserRelation;
import com.team.sns.services.UserFollowService;
import com.team.sns.services.UserService;

/**
 * @author seven zhao
 * @version 1.0
 * 功能说明：测试用户service功能
 * 说明：由于Myeclipse中javaEE5.0中jar包和hibernate-jpa-2.0-api-1.0.0.Final.jar有冲突，所以在进行junit测试时，需要
 *     移除java EE 5 Libraries，但是在web运行时必须加上。否则将会报错：
 *     java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
 *     这是新版本的bug，如hibernate改为3.3也可以解决
 */
public class UserTest {

	
	private static ApplicationContext context = null;
	private static UserService  service= null;
	private static UserFollowService userFollowService = null;
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		context = new ClassPathXmlApplicationContext("applicationContext.xml");
		service = (UserService) context.getBean("userServiceBean");
		userFollowService = (UserFollowService) context.getBean("userFollowServiceImpl");
	}
	@Test
	public void testChkUsername(){
		System.out.println(service);
		String username = "ffffff";
		boolean flag = service.chkUsername(username);
		System.out.println(flag);
	}
	
	@Test
	public void testSaveFollow() {
		UserRelation ur = new UserRelation();
		ur.setType(1);
		/*User_Follow uf = new User_Follow();
		uf.setUserId(1);
		uf.setFollowId(2);
		ur.setId(uf);*/
		userFollowService.save(ur);
	}
	
	@Test
	public void testCreateMessage() {
		
	}
}
